// Learn TypeScript:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/typescript.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class Loading extends cc.Component {

    progressBar:cc.ProgressBar
    text:cc.Label;

    
    stext = "网络连接中";
    ptext = "";
    time=0;
    onLoad () {
        this.progressBar = this.getComponent(cc.ProgressBar);
        this.text = this.node.getChildByName("text").getComponent(cc.Label);
        this.progressBar.progress = 0;
        this.text.string = "网络连接中";
    }

    start () {

    }

    update (dt) {        
        this.progressBar.progress+=0.01;
        if(this.progressBar.progress>1){
            this.progressBar.progress=0;
        }
        
        this.time+=dt;

        if(this.time>0.5){
            if(this.ptext.length>=3){
                this.ptext = "";
            }else{
                this.ptext+=".";
            }
            this.text.string = this.stext+this.ptext;
            this.time = 0;
        }


    }
}
